package logic

import (
	"context"
	"tiktok/model/mysql"
	"tiktok/rpc/internal/svc"
	"tiktok/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type LoginLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
	return &LoginLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// ToDo:登录

func (l *LoginLogic) Login(in *pb.LoginReq) (*pb.LoginResp, error) {
	// todo: add your logic here and delete this line
	tiktok := mysql.Tiktok{
		Name:     in.Name,
		Phone:    in.Phone,
		Password: in.Password,
	}
	if tiktok.Phone != in.Phone || tiktok.Password != in.Password {
		logx.Error("登录错误,用户名或者密码不对请您核实!")
	}
	return &pb.LoginResp{Name: tiktok.Name, Phone: tiktok.Phone, Password: tiktok.Password}, nil
}
